﻿using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace DDD.Extensions
{
    public static class AutofacExtension
    {
        public static IHostBuilder AddAutofac(this IHostBuilder hostBuilder, Action<HostBuilderContext, ContainerBuilder> configureDelegate)
        {
            hostBuilder.UseServiceProviderFactory(new AutofacServiceProviderFactory());
            hostBuilder.ConfigureContainer<ContainerBuilder>(configureDelegate);

            return hostBuilder;
        }
    }
}
